package hu.ikti.obr.sync.manager;

import hu.ikti.obr.sync.manager.service.SynchronisationManager;
import hu.ikti.obr.sync.manager.service.impl.SynchronisationManagerImpl;

import java.util.Dictionary;
import java.util.Hashtable;

import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
import org.osgi.framework.ServiceRegistration;
import org.osgi.service.obr.RepositoryAdmin;

public class Activator implements BundleActivator {

	private ServiceRegistration registration;

	public void start(BundleContext context) throws Exception {
		ServiceReference ref = context
				.getServiceReference(RepositoryAdmin.class.getName());
		RepositoryAdmin repositoryAdmin = (RepositoryAdmin) context
				.getService(ref);

		Dictionary<String, String> props = new Hashtable<String, String>();

		props.put("service.exported.interfaces", "*");
		props.put("service.exported.configs", "org.apache.cxf.ws");
		props.put("org.apache.cxf.ws.address", "http://192.168.1.2:9090/sync");

		registration = context.registerService(
				SynchronisationManager.class.getName(),
				new SynchronisationManagerImpl(repositoryAdmin, context), props);
	}

	public void stop(BundleContext context) throws Exception {
		registration.unregister();
	}

}
